<?php

class {$controller_name}_model extends CI_Model
{
    public $table_name = '{$pre_fix}{$controller_lower}';

    public function get($id)
    {
        $query = $this->db->get_where($this->table_name , array('id' => $id));
        return $query->row();
    }

    public function listAll()
    {
        $query = $this->db->get($this->table_name);
        return $query->result();
    }

    public function save($data)
    {
        $save_data = array();
        {$data_str}

        if($this->get($data['id']))
        {
            return $this->db->update($this->tableName, $save_data, array('id' => $data['id']));
        }

        return $this->db->insert($this->table_name, $save_data);
    }

    public function delete($id)
    {
        if(!$id)
        {
            return false;
        }

        return $this->db->query($this->table_name, array('id'=> $id));
    }
}